from visual_object import VisualObject2D
from panda3d.core import Vec3,Vec4
import copy
'''
	Andrew Oberlin
	Date Created: February 27, 2012
	Date Last Modified: February 27, 2012
'''
class TitleScreen(VisualObject2D):
	'''
		Creates the TitleScreen object for use
	'''
	def __init__(self, parent):
		self.scale = Vec3(2.67, 1, 2)
		self.texturePath = "models/gui/game_maker/2d_game_in_a_box_logo.png"
		self.parent = parent
		self.loadModel(self.texturePath, self.scale)
		#self.parent.soundLoader.playMusic('menu')
		
		
	'''
		Hides the title screen
	'''
	def hide(self):
		self.model.hide()
		
	'''
		Hides the title screen
	'''
	def show(self):
		self.model.show()
		
		
	'''
		Resizes the title screen to fit the screen
		Also maintains the aspect ratio
		
		Does not work with fullscreen
	'''
	def __handleAspectChange(self):
		props = self.parent.base.win.getProperties()
		curAspect = props.getXSize()*1.0/props.getYSize()
		if (curAspect != self.parent.WIN_WIDTH/self.parent.WIN_HEIGHT):
			curAspect = self.parent.WIN_WIDTH/self.parent.WIN_HEIGHT
			tmp = copy.deepcopy(props)
			tmp.setSize(props.getXSize(), props.getXSize() / curAspect)
			self.parent.base.win.requestProperties(tmp)
		newScale = 2 * curAspect
		self.scale = Vec3(newScale, 1, 2)
		self.model.setScale(self.scale)